var app = getApp();

Page({
    data: {
        list: [],
        hydl: !0
    },
    toredbag:function(t){
        setTimeout(()=>{
            var n = this,u = wx.getStorageSync("users").id;
            console.log(u,'u')
            console.log(n.data.code)
            if(u==''){
                wx.showModal({
                    title: "获取信息失败",
                    content: "为您跳转首页，请重新扫码获取红包",
                    success: function(e) {
                        wx.navigateTo({
                          
                            url: "../index/index"
                        });
                    }
                });
               
            }else{
                wx.navigateTo({
                    url: "../lmredbag/redbag?uid="+u+"&code="+n.data.code
                });
            }
        },2000)
       
        
    },
    onLoad: function(o) {
        var n = this;
        n.setData({
            code:o.scene
        })
    },
    updateUserInfo: function(t) {
        console.log(t), "getUserInfo:ok" == t.detail.errMsg && (this.setData({
            hydl: !1
        }), this.reload());
    },
    reload: function(t) {
        var c = this, i = this.data.fxzuid;
        console.log(i), wx.login({
            success: function(t) {
                console.log('执行了')
                var e = t.code;
                wx.setStorageSync("code", e), wx.getSetting({
                    success: function(t) {
                        console.log(t), t.authSetting["scope.userInfo"] ? wx.getUserInfo({
                            success: function(t) {
                                console.log(t), wx.setStorageSync("user_info", t.userInfo);
                                var a = t.userInfo.nickName, n = t.userInfo.avatarUrl;
                                app.util.request({
                                    url: "entry/wxapp/openid",
                                    cachetime: "0",
                                    data: {
                                        code: e
                                    },
                                    success: function(t) {
                                        console.log(t), wx.setStorageSync("key", t.data.session_key), wx.setStorageSync("openid", t.data.openid);
                                        var e = t.data.openid,u = t.data.unionid;
                                        app.util.request({
                                            url: "entry/wxapp/Login",
                                            cachetime: "0",
                                            data: {
                                                openid: e,
                                                unionid: u,
                                                img: n,
                                                cityname: wx.getStorageSync("city"),
                                                name: a
                                            },
                                            success: function(t) {
                                                console.log(t), c.setData({
                                                    userinfo: t.data
                                                }), wx.setStorageSync("users", t.data), wx.setStorageSync("uniacid", t.data.uniacid), 
                                                null != i && app.util.request({
                                                    url: "entry/wxapp/Binding",
                                                    cachetime: "0",
                                                    data: {
                                                        fx_user: t.data.id,
                                                        user_id: i
                                                    },
                                                    success: function(t) {
                                                        console.log(t);
                                                    }
                                                });
                                            }
                                        });
                                    }
                                });
                            }
                        }) : (console.log("未授权过"), c.setData({
                            hydl: !0
                        }));
                    }
                });
            }
        })
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
});